// import { appConfig } from '@/config'
import Jenkins from 'jenkins'

// const JENKINS_BASE_URL = 'http://ws:ws#11@localhost:18080/jenkins';

export class JenkinsService {
  private static _client: Jenkins | null = null

  private static get client(): Jenkins {
    if (!this._client) {
      this._client = new Jenkins({
        // baseUrl: appConfig.get('jenkins_base_url') || '',
        baseUrl: 'http://ws:ws#11@localhost:18080/jenkins',
      })
    }
    return this._client
  }

  /** 获取 Jenkins job 列表
   *
   */
  static getJobs() {
    return this.client.job.list()
  }

  /** 获取 Jenkins job
   *
   * @param name
   */
  static getJob(name: string) {
    return this.client.job.get(name)
  }
}
